home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / PowerPlant / AGA Slider 1.0 / Sources / CSliderDemoWindow.cp < prev    next >
Encoding:
Text File  |  1996-06-25  |  1.6 KB  |  75 lines  |  [TEXT/CWIE]

  1. //
  2. //    CSliderDemoWindow.cp
  3. //
  4.  
  5. #include "CSliderDemoWindow.h"
  6. #include "CAGASlider.h"
  7. #include <LString.h>
  8.  
  9. const MessageT    msg_VerticalSlider     = 1001;
  10. const MessageT    msg_EastSlider         = 1002;
  11. const MessageT    msg_WestSlider         = 1003;
  12. const MessageT    msg_HorizontalSlider = 1004;
  13. const MessageT    msg_SouthSlider     = 1005;
  14. const MessageT    msg_NorthSlider     = 1006;
  15.  
  16. const PaneIDT    pane_ResultField    = 1100;
  17.  
  18. CSliderDemoWindow*    CSliderDemoWindow::CreateSliderDemoWindowStream(LStream *inStream)
  19. {
  20.     return new CSliderDemoWindow( inStream );
  21. }
  22.  
  23. CSliderDemoWindow::CSliderDemoWindow( LStream *inStream )
  24.     : LWindow( inStream )
  25. {
  26.  
  27. }
  28.  
  29. void    CSliderDemoWindow::ListenToMessage( MessageT inMessage, void *ioParam )
  30. {
  31.     Int32 theValue = *(Int32*)ioParam;
  32.     StringPtr ind;
  33.     Str15 ind_4 = "\p'xxxx'";
  34.     
  35.     switch ( inMessage ) {
  36.     case 'enab':    DoSliderEnable( theValue == 1 ); return;
  37.     case 'vert':    ind = "\pVertical"; break;
  38.     case 'east':    ind = "\pEast";     break;
  39.     case 'west':    ind = "\pWest";     break;
  40.     case 'hori':    ind = "\pHorizontal"; break;
  41.     case 'sout':    ind = "\pSouth";     break;
  42.     case 'nort':    ind = "\pNorth";     break;
  43.  
  44.     default:    // unknown message
  45.         ind = ind_4;
  46.         *(long*)(ind_4+2) = inMessage;
  47.         break;
  48.     }
  49.     
  50.     LStr255 str(theValue);
  51.     str += ' ';
  52.     str += ind;
  53.     
  54.     LEditField *theField = (LEditField*)FindPaneByID( pane_ResultField );
  55.     Assert_( theField != nil );
  56.     
  57.     theField->SetDescriptor( str );
  58.     theField->Draw( nil );
  59.     
  60. }
  61.  
  62. void CSliderDemoWindow::DoSliderEnable( Boolean inEnable )
  63. {
  64.     for ( PaneIDT p = 1001; p<=1006; p++ ) {
  65.     
  66.         LPane * thePane = FindPaneByID( p );
  67.         Assert_( thePane != nil );
  68.         
  69.         if ( inEnable ) thePane->Enable();
  70.         else thePane->Disable();
  71.         
  72.         thePane->Draw( nil );
  73.     }
  74. }
  75.